<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        console.time();
        function findEarliestAndLatestTime(data) {
            // 将数据展平成一维数组，并分割每个时间范围字符串
            const times = data.flatMap(range => {
                const [start, end] = range.split('-');
                return [start, end];
            });

            // 找出最早的开始时间和最晚的结束时间
            const earliestStart = times.reduce((acc, time) => {
                return time < acc ? time : acc;
            }, times[0]);

            const latestEnd = times.reduce((acc, time) => {
                return time > acc ? time : acc;
            }, times[0]);

            return {
                start: earliestStart,
                end: latestEnd
            };
        }

        function generateTimes(startTime, endTime) {
            const startTimeArr = startTime.split('/').map(Number);
            const endTimeArr = endTime.split('/').map(Number);

            let currentHour = startTimeArr[0];
            let currentMinute = startTimeArr[1];
            let currentSecond = startTimeArr[2];
            let times = [];

            while (currentHour < endTimeArr[0] ||
                (currentHour === endTimeArr[0] && currentMinute < endTimeArr[1]) ||
                (currentHour === endTimeArr[0] && currentMinute === endTimeArr[1] && currentSecond <= endTimeArr[2])) {

                times.push(formatTime(currentHour, currentMinute, currentSecond));
                currentSecond++;
                if (currentSecond === 60) {
                    currentSecond = 0;
                    currentMinute++;
                }
                if (currentMinute === 60) {
                    currentMinute = 0;
                    currentHour++;
                }
                if (currentHour === 24) {
                    currentHour = 0;
                }
            }

            return times;
        }

        function formatTime(hour, minute, second) {
            return `${String(hour).padStart(2, '0')}/${String(minute).padStart(2, '0')}/${String(second).padStart(2, '0')}`;
        }
        const data = [
            "00/00/00-23/59/58",
        ];
        const newTimer = ['02/03/20', '07/00/00']
        const { start, end } = findEarliestAndLatestTime(data)
        console.log(generateTimes(start, end));
        const isBContainedInA = newTimer.every(element => generateTimes(start, end).includes(element));

        console.log(isBContainedInA); // 输出：true
        console.timeEnd();
    </script>
</body>

</html>
